package me.jessyan.armscomponent.app.mvp.ui.activity.mine;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import org.jetbrains.annotations.NotNull;

import butterknife.OnClick;
import me.jessyan.armscomponent.app.R;
import me.jessyan.armscomponent.app.di.component.DaggerMineSetUserinfoComponent;
import me.jessyan.armscomponent.app.mvp.contract.mine.MineSetUserinfoContract;
import me.jessyan.armscomponent.app.mvp.presenter.mine.MineSetUserinfoPresenter;
import me.jessyan.armscomponent.commonsdk.core.RouterHub;
import me.jessyan.armscomponent.commonsdk.utils.Utils;

import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * <p>
 * Author: Taozebi
 * Date: 08/08/2021 17:59
 * Description: 个人中心-设置个人信息
 */

@Route(path = RouterHub.MINE_SETUSERINFOACTIVITY)
public class MineSetUserinfoActivity extends BaseActivity<MineSetUserinfoPresenter> implements MineSetUserinfoContract.View {


    @Override
    public void setupActivityComponent(@NotNull @NonNull AppComponent appComponent) {
        DaggerMineSetUserinfoComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }


    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.mine_activity_setting_userinfo; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        loadTitle();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    private void loadTitle() {
        setTitle("账号/头像设置");
    }

    @OnClick({R.id.mine_rl_set_avatar,R.id.mine_rl_set_username})
    public void onClicked(View view){
        int id = view.getId();
        if(id == R.id.mine_rl_set_avatar){
            if(Utils.isFastClick()){
                showMessage("设置头像");
            }
        }else if(id == R.id.mine_rl_set_username){
            if(Utils.isFastClick()){
                showMessage("设置账号");
            }
        }
    }
}
